package org.akomantoso.core.data;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.akomantoso.core.io.Input;
import org.akomantoso.core.io.Output;

/**
 * <pre>
 * <xsd:element name="tr">
 * 		<xsd:complexType>
 * 			<xsd:choice minOccurs="1" maxOccurs="unbounded">
 * 				<xsd:element ref="th"/>
 * 				<xsd:element ref="td"/>
 * 			</xsd:choice>
 * 			<xsd:attributeGroup ref="coreopt"/>
 * 		</xsd:complexType>
 * </xsd:element>
 * </pre>
 * 
 * @author <a href="mailto:jacques.militello@gmail.com">Jacques Militello</a>
 * 
 * @since http://www.akomantoso.org/1.0
 */
public final class Tr extends CoreOptImpl {

	public static final String ELEMENT = "tr";

	// Mandatory (min 1)
	private final List<TrElement> _trs = new ArrayList<TrElement>(4);

	public List<TrElement> getTrs() {
		return _trs;
	}

	public void addTrElement(TrElement trElement) {
		_trs.add(trElement);
	}

	/**
	 * @see org.akomantoso.core.io.Externalizable#writeExternal(org.akomantoso.core.io.Output)
	 */
	public <T extends Output> void writeExternal(T out) throws IOException {
		out.writeStart(ELEMENT);
		super.writeExternal(out);
		for (int i = 0, n = _trs.size(); i < n; i++) {
			_trs.get(i).writeExternal(out);
		}
		out.writeEnd();
	}

	/**
	 * @see org.akomantoso.core.io.Externalizable#readExternal(org.akomantoso.core.io.Input)
	 */
	public <T extends Input> void readExternal(T in) throws IOException {
		super.readExternal(in);
		// TODO
	}

}